package com.epam.my.Kulibaba;

public class Email implements Comparable<Email> {
	public String senderName;
	public String senderAddress;
	public String emailSubject;

	public Email withSenderName(String name) {
		this.senderName = name;
		return this;
	}

	public Email withSenderAdress(String address) {
		this.senderAddress = address;
		return this;
	}

	public Email withSubjectEmail(String subject) {
		this.emailSubject = subject;
		return this;
	}

		public int compareTo(Email other) {
		return this.senderName.compareTo(other.senderName);
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((emailSubject == null) ? 0 : emailSubject.hashCode());
		result = prime * result
				+ ((senderName == null) ? 0 : senderName.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Email other = (Email) obj;
		if (emailSubject == null) {
			if (other.emailSubject != null)
				return false;
		} else if (!emailSubject.equals(other.emailSubject))
			return false;
		if (senderName == null) {
			if (other.senderName != null)
				return false;
		} else if (!senderName.equals(other.senderName))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "Email [senderName=" + senderName + ", emailSubject="
				+ emailSubject + "]";
	}
}
